package com.ruoyi.system.controller;

import java.util.List;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.system.domain.Ds;
import com.ruoyi.system.domain.DsRegioninfo;
import com.ruoyi.system.service.IDsRegioninfoService;
import com.ruoyi.system.service.IDsSpecialregionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;


/**
 * 区域管理Controller
 * 
 * @author ruoyi
 * @date 2024-05-27
 */
@RestController
@RequestMapping("/system/regioninfo")
public class DsRegioninfoController extends BaseController
{
    @Autowired
    private IDsRegioninfoService dsRegioninfoService;


    /**
     * 查询区域管理列表
     */
    @PreAuthorize("@ss.hasPermi('system:regioninfo:list')")
    @GetMapping("/list")
    public TableDataInfo list(DsRegioninfo dsRegioninfo)
    {
        startPage();
        List<DsRegioninfo> list = dsRegioninfoService.selectDsRegioninfoList(dsRegioninfo);
        System.out.println(list);
        return getDataTable(list);
    }

    /**
     * 导出区域管理列表
     */
    @PreAuthorize("@ss.hasPermi('system:regioninfo:export')")
    @Log(title = "区域管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, DsRegioninfo dsRegioninfo)
    {
        List<DsRegioninfo> list = dsRegioninfoService.selectDsRegioninfoList(dsRegioninfo);
        ExcelUtil<DsRegioninfo> util = new ExcelUtil<DsRegioninfo>(DsRegioninfo.class);
        util.exportExcel(response, list, "区域管理数据");
    }

    /**
     * 获取区域管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:regioninfo:query')")
    @GetMapping(value = "/{regionId}")
    public AjaxResult getInfo(@PathVariable("regionId") Long regionId)
    {
        return success(dsRegioninfoService.selectDsRegioninfoByRegionId(regionId));
    }

    /**
     * 新增区域管理
     */
    @PreAuthorize("@ss.hasPermi('system:regioninfo:add')")
    @Log(title = "区域管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody DsRegioninfo dsRegioninfo)
    {
        return toAjax(dsRegioninfoService.insertDsRegioninfo(dsRegioninfo));
    }

    /**
     * 修改区域管理
     */
    @PreAuthorize("@ss.hasPermi('system:regioninfo:edit')")
    @Log(title = "区域管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody DsRegioninfo dsRegioninfo)
    {
        return toAjax(dsRegioninfoService.updateDsRegioninfo(dsRegioninfo));
    }

    /**
     * 删除区域管理
     */
    @PreAuthorize("@ss.hasPermi('system:regioninfo:remove')")
    @Log(title = "区域管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{regionIds}")
    public AjaxResult remove(@PathVariable Long[] regionIds)
    {
        return toAjax(dsRegioninfoService.deleteDsRegioninfoByRegionIds(regionIds));
    }

    @PreAuthorize("@ss.hasPermi('system:regioninfo:name')")
    @RequestMapping("/storeyname")
    public  AjaxResult selectStoreyName (){
        List<DsRegioninfo> list=dsRegioninfoService.selectStoreyName();
        return success(list);
    }

    @PreAuthorize("@ss.hasPermi('system:regioninfo:ling')")
    @RequestMapping("/storey")
    public AjaxResult selectStorey(){
        List<DsRegioninfo> list=dsRegioninfoService.selectdsregioninfo();
        return success(list);
    }




}
